//
//  SearchHeader.swift
//  shop
//
//  Created by chen on 2025/5/17.
//

import SwiftUI

struct SearchHeader: View {
    
    @Environment(\.dismiss) private var dismiss
    
    var keyWord: String
    
    var body: some View {
        HStack(spacing: 3) {
            // 返回按钮
            Button {
                dismiss()
            } label: {
                Image(systemName: "chevron.left")
                    .foregroundColor(.black)
                    .font(.system(size: 20))
            }

            Spacer()
            
            // 搜索框
            HStack(spacing: 10) {
                Button {
                    dismiss()
                } label: {
                    HStack(spacing: 5) {
                        Text("\(keyWord)")
                            .font(.system(size: 14))
                        
                        Image(systemName: "xmark")
                            .font(.system(size: 10))
                            .bold()
                    }
                    .padding(.horizontal, 10)
                    .padding(.vertical, 5)
                    .background(.white)
                    .cornerRadius(15)
                    .foregroundStyle(.black)
                }
                .buttonStyle(PlainButtonStyle())
                
                Spacer()
            }
            .padding(.vertical, 5)
            .padding(.horizontal, 3)
            .frame(maxWidth: .infinity)
            .background(Color.searchBg)
            .cornerRadius(20)
        }
        .padding(.horizontal, 10)
        .padding(.bottom, 8)
        .background(.white)
    }
}
